package com.gbq.service.impl;

import com.gbq.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class RedisServiceImpl implements RedisService{


    @Autowired
    RedisTemplate redisTemplate;
    @Autowired
    RedisService redisService;

    @Override
    public JSONObject selectPersonByCardno(String cardno){
        RedisSerializer<String> serializer = new StringRedisSerializer();
        ValueOperations<String,Object> valueOperations = redisTemplate.opsForValue();
        redisTemplate.setKeySerializer(serializer);
        redisTemplate.setValueSerializer(serializer);

        JSONObject obj = JSONObject.fromObject(valueOperations.get("T_PERSON_ON_BLACK_LIST"+cardno));

        return obj ;
    }

    @Override
    public JSONObject selectByCarno(String carno) {
        RedisSerializer<String> serializer = new StringRedisSerializer();
        ValueOperations<String,Object> valueOperations = redisTemplate.opsForValue();
        redisTemplate.setKeySerializer(serializer);
        redisTemplate.setValueSerializer(serializer);

        JSONObject obj = JSONObject.fromObject(valueOperations.get("CAR_CTRL"+carno));

        return obj ;
    }


}
